<html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="/layouts/default.xhtml">
    <ui:define name="title">#{text['import.title']}</ui:define>
    <ui:param name="menu" value="AdminMenu"/>
    <ui:param name="menuleft" value="ImportMenu"/>

    <ui:define name="body">

        <div class="col-lg-9">
	        <div class="page-header">
				<h3>#{text['import.title']}</h3>
			</div>
			
	        <h:form id="importForm" enctype="multipart/form-data">
				
				<div class="row">
					<div class="col-sm-4 form-group">
						<h:outputLabel styleClass="control-label" for="classeurName" value="#{text['import.classeur.name']}" />
							<h:inputText id="classeurName" value="#{eleveController.classeurName}" styleClass="form-control" required="true" maxlength="50">
								<p:ajax partialSubmit="true"/>
							</h:inputText>
							
						<p:message for="classeurName" />
					</div>
				</div>
				
				<div class="row">
					<div class="col-sm-4 form-group">
						<h:outputLabel styleClass="control-label" for="classe" value="#{text['eleve.classe']}" />
						<h:selectOneMenu id="classe" styleClass="form-control" value="#{eleveController.eleve.groupe.classe.id}" required="true">
							<f:selectItems value="#{eleveController.classes}" var="classe" itemLabel="#{classe.nomClasse}" itemValue="#{classe.id}" />
							<p:ajax partialSubmit="true" update="groupe" listener="#{eleveController.handleGroupeChange}" /> 
						</h:selectOneMenu>
						<p:message for="classe" />
					</div>
				</div>
				
				<div class="row">
					<div class="col-sm-4 form-group">
						<h:outputLabel styleClass="control-label" for="groupe" value="#{text['eleve.groupe']}" />
						<h:selectOneMenu id="groupe" styleClass="form-control" value="#{eleveController.eleve.groupe.id}" required="true">
							<f:selectItems value="#{eleveController.groupes}" var="groupe" itemLabel="#{groupe.libelleGroupe}" itemValue="#{groupe.id}" />
						</h:selectOneMenu>
						<p:message for="classe" />
					</div>
				</div>
					      
		        <div class="row">
					<div class="form-group">
	           			<h:outputLabel styleClass="control-label" for="fileEleves" value="#{text['import.file']}"/>
	       				<p:fileUpload id="fileEleves" fileUploadListener="#{eleveController.handleFileElevesUpload}" mode="advanced"
            					process="@form" update="@form" auto="true" sizeLimit="10000000000000000" allowTypes="/(\.|\/)(xls)$/"/>
	            		<p:message for="fileEleves"/>
	            	</div>
		        </div>
		        
				<div class="row">
					<div class="page-header">
						<h3>#{text['import.list.eleve']}</h3>
					</div>
				</div>
				
				<div class="row">
					<div class="btn-group">
						<p:dataTable id="eleves" var="eleve" value="#{eleveController.importResult}">
							
							<p:column headerText="#{text['eleve.numInsc']}" sortBy="numeroInscription">
								<h:outputText value="#{eleve.numeroInscription}" escape="true" />
							</p:column>
							
							<p:column headerText="#{text['eleve.nom']}" sortBy="fullName">
								<h:outputText value="#{eleve.nom}" escape="true" />
							</p:column>
							
							<p:column headerText="#{text['eleve.prenom']}" sortBy="fullName">
								<h:outputText value="#{eleve.prenom}" escape="true" />
							</p:column>
							
							<p:column headerText="#{text['eleve.nomAr']}" sortBy="fullName">
								<h:outputText value="#{eleve.nomAr}" escape="true" />
							</p:column>
							
							<p:column headerText="#{text['eleve.prenomAr']}" sortBy="fullNameAr">
								<h:outputText value="#{eleve.prenomAr}" escape="true" />
							</p:column>
							
							<p:column headerText="#{text['eleve.lieuNaissance']}" sortBy="fullNameAr">
								<h:outputText value="#{eleve.lieuNaissance}" escape="true" />
							</p:column>
							
							<p:column headerText="#{text['eleve.lieuNaissanceAr']}" sortBy="fullNameAr">
								<h:outputText value="#{eleve.lieuNaissanceAr}" escape="true" />
							</p:column>
							
							<p:column headerText="#{text['eleve.dateNaissance']}" sortBy="dateNaissance">
								<h:outputText value="#{eleve.dateNaissance}" escape="true">
									<f:convertDateTime pattern="#{text['date.format']}" />
								</h:outputText>
							</p:column>
							
						</p:dataTable>
					</div>
				</div>
				<div class="row">
		            <div class="btn-group">
		                <h:commandButton value="#{text['button.save']}" action="#{eleveController.importe}"
		                    id="save" styleClass="btn btn-primary"/>
		            </div>
	            </div>
	            
	        </h:form>
        </div>
    </ui:define>
</ui:composition>
</html>
